package com.tongji.housediy.controller.designCMD
{
	import com.tongji.housediy.events.designEvent.SaveDeleteDesignEvent;
	import com.tongji.housediy.model.DesignModel;
	import com.tongji.housediy.model.ExchangeDataModel;
	import com.tongji.housediy.service.DesignService;
	
	import org.robotlegs.mvcs.Command;
	
	/**
	 * 
	 * @author yanghanbing
	 * 2011/4/11
	 */ 
	public class SaveDeleteDesignCommand extends Command
	{
		[Inject]
		public var designModel:DesignModel;
		
		[Inject]
		public var event:SaveDeleteDesignEvent;
		
		[Inject]
		public var service:DesignService;
		
		override public function execute():void
		{
			switch(event.type)
			{
				case SaveDeleteDesignEvent.SAVE_DESIGN:
					service.saveDesignByUser(event.design);
					break;
				case SaveDeleteDesignEvent.SAVE_DESIGN_RESULT:
					designModel.updateDesignModel(event.designArray);
					break;
				case SaveDeleteDesignEvent.DELETE_DESIGN:
					service.deleteDesign(event.design);
					break;					
			}
		}
	}
}